package com.logicwin.RobotTravel.utils;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;

public class SystemParams {
	public static int getWindowWidth(Context activity) {
		Display display = ((Activity)activity).getWindowManager().getDefaultDisplay();
		return display.getWidth();
	}
	
	public static int getWindowHeight(Context activity) {
		Display display = ((Activity)activity).getWindowManager().getDefaultDisplay();
		return display.getHeight();
	}
	
	public static Bitmap adjustBitmapBasedOnScreen(Bitmap bitmap, Activity activity)
    {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();

        int newWidth = getWindowWidth(activity);
        int newHeight = getWindowHeight(activity);

        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
Log.i("SystemParams", "width=" + width + " height=" + height + " newWidth=" + newWidth + " newHeight=" + newHeight);
        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);
        
        Bitmap newbm = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix,
                true);
        return newbm;
    }
}
